erDiagram
    users {
        BIGINT id PK
        VARCHAR username UK
        VARCHAR email UK
        VARCHAR password_hash
        VARCHAR avatar_url
        ENUM status
        TIMESTAMP created_at
        TIMESTAMP updated_at
        TIMESTAMP last_login_at
    }
    
    conversations {
        BIGINT id PK
        BIGINT user_id FK
        VARCHAR title
        TEXT description
        ENUM status
        INT message_count
        TIMESTAMP created_at
        TIMESTAMP updated_at
    }
    
    messages {
        BIGINT id PK
        BIGINT conversation_id FK
        ENUM role
        TEXT content
        INT message_order
        INT token_count
        VARCHAR model_name
        INT processing_time_ms
        TIMESTAMP created_at
    }
    
    favorites {
        BIGINT id PK
        BIGINT user_id FK
        BIGINT conversation_id FK
        TEXT notes
        TIMESTAMP created_at
    }
    
    user_sessions {
        BIGINT id PK
        BIGINT user_id FK
        VARCHAR session_token UK
        TIMESTAMP expires_at
        VARCHAR ip_address
        TEXT user_agent
        TIMESTAMP created_at
    }
    
    users ||--o{ conversations : "has"
    users ||--o{ favorites : "creates"
    users ||--o{ user_sessions : "has"
    conversations ||--o{ messages : "contains"
    conversations ||--o{ favorites : "favorited_in" 